// 导入组件
import Vue from 'vue';
import Router from 'vue-router';
// 首页
import index from '@/views/index';
// 图表界面
import statistics from '@/views/charts/statistics';

// 启用路由
Vue.use(Router);

// 导出路由 
export default new Router({
    routes: [{
        path: '/',
        name: '',
        component: () => import('@/views/login'),
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/login',
        name: 'login',
        component: () => import('@/views/login'),
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/index',
        name: 'index',
        component: () => import('@/views/index'),
        iconCls: 'el-icon-tickets',
        children: [{
            path: '/charts/statistics',
            name: 'home',
            component: statistics,
            meta: {
                requireAuth: true,
                title: '首页'
            }
        },
        {
            path: '/user/list',
            name: '用户列表',
            component: () => import('@/views/user/List'),
            meta: {
                requireAuth: true,
                title: '用户列表'
            }
        },
        {
            path: '/order',
            name: 'order',
            component: () => import('@/views/order/Index'),
            meta: {
                requireAuth: true,
                title: '订单'
            },
            children: [
                {
                    path: '/order/list',
                    name: 'order_list',
                    component: () => import('@/views/order/List'),
                    meta: {
                        requireAuth: true,
                        title: '订单列表'
                    }
                },
                {
                    path: '/order/order_detail',
                    name: 'order_order_detail',
                    component: () => import('@/views/order/OrderDetail'),
                    meta: {
                        requireAuth: true,
                        title: '订单详情',
                        activeMenu: '/order/list'
                    }
                },
            ]
        },
        {
            path: '/goods',
            name: '商品',
            component: () => import('@/views/goods/Index'),
            meta: {
                requireAuth: true,
                title: '商品'
            },
            children: [
                {
                    path: '/goods/list',
                    name: 'goods_list',
                    component: () => import('@/views/goods/Goods'),
                    meta: {
                        requireAuth: true,
                        title: '平台商品'
                    },
                },
                {
                    path: '/goods/add',
                    name: 'add_goods',
                    component: () => import('@/views/goods/Create'),
                    meta: {
                        requireAuth: true,
                        title: '添加商品',
                        activeMenu: '/goods/supplier_list'
                    }
                },
                {
                    path: '/goods/edit',
                    name: 'edit_goods',
                    component: () => import('@/views/goods/Create'),
                    meta: {
                        requireAuth: true,
                        title: '编辑商品',
                        activeMenu: '/goods/supplier_list'
                    }
                },
                {
                    path: '/goods/add_quotation/:id',
                    name: 'add_quotation',
                    component: () => import('@/views/goods/Quotation'),
                    meta: {
                        requireAuth: true,
                        title: '商品报价',
                        activeMenu: '/goods/list'
                    }
                },
                {
                    path: '/goods/supplier_list',
                    name: 'goods_supplier_list',
                    component: () => import('@/views/goods/SupplierList'),
                    meta: {
                        requireAuth: true,
                        title: '供应商商品'
                    }
                },
                {
                    path: '/goods/category',
                    name: '商品分类',
                    component: () => import('@/views/goods/Category'),
                    meta: {
                        requireAuth: true,
                        title: '商品分类'
                    }
                },
            ]
        },
        {
            path: '/driver',
            name: 'driver',
            component: () => import('@/views/driver/Index'),
            meta: {
                requireAuth: true,
                title: '司机'
            },
            children: [
                {
                    path: '/driver/list',
                    name: 'driver_list',
                    component: () => import('@/views/driver/List'),
                    meta: {
                        requireAuth: true,
                        title: '司机管理'
                    },
                },
                {
                    path: '/driver/contract',
                    name: 'driver_contract',
                    component: () => import('@/views/driver/contract/contractIndex'),
                    meta: {
                        requireAuth: true,
                        title: '合同',
                        activeMenu: '/driver/list'
                    },
                    children: [
                        {
                            path: '/driver/contract/list/:id',
                            name: 'driver_contract_list',
                            component: () => import('@/views/driver/contract/List'),
                            meta: {
                                requireAuth: true,
                                title: '合同管理',
                                activeMenu: '/driver/list'
                            },
                        }
                    ]
                },
            ]
        },
        {
            path: '/contract',
            name: 'contract',
            component: () => import('@/views/contract/Index'),
            meta: {
                requireAuth: true,
                title: '合同'
            },
            children: [
                {
                    path: '/contract/list',
                    name: 'contract_list',
                    component: () => import('@/views/contract/List'),
                    meta: {
                        requireAuth: true,
                        title: '合同管理'
                    },
                }
            ]
        },
        {
            path: '/setting',
            name: 'setting',
            component: () => import('@/views/setting/Index'),
            meta: {
                requireAuth: true,
                title: '设置'
            },
            children: [
                {
                    path: '/setting/system',
                    name: '系统设置',
                    component: () => import('@/views/setting/System'),
                    meta: {
                        requireAuth: true,
                        title: '系统设置'
                    }
                },
                {
                    path: '/setting/address_list',
                    name: '地址',
                    component: () => import('@/views/setting/AddressList'),
                    meta: {
                        requireAuth: true,
                        title: '地址列表'
                    }
                },
            ]
        },
        {
            path: '/staff',
            name: 'staff',
            component: () => import('@/views/staff/StaffIndex'),
            meta: {
                requireAuth: true,
                title: '员工'
            },
            children: [
                {
                    path: '/staff/permission',
                    name: 'staff_permission',
                    component: () => import('@/views/staff/Permission'),
                    meta: {
                        requireAuth: true,
                        title: '角色管理'
                    }
                },
                {
                    path: '/staff/list',
                    name: 'staff_list',
                    component: () => import('@/views/staff/List'),
                    meta: {
                        requireAuth: true,
                        title: '员工管理'
                    }
                },
            ]
        },
        {
            path: '/finance',
            name: 'finance',
            component: () => import('@/views/finance/Index'),
            meta: {
                requireAuth: true,
                title: '财务'
            },
            children: [
                {
                    path: '/finance/list',
                    name: 'finance_list',
                    component: () => import('@/views/finance/List'),
                    meta: {
                        requireAuth: true,
                        title: '账单列表'
                    },
                },
            ]
        },

        {
            path: '/personal/edit_pwd',
            name: 'edit_pwd',
            component: () => import('@/views/personal/EditPwd'),
            meta: {
                requireAuth: true,
                title: '修改密码'
            }
        },
        {
            path: '/personal/supply_info',
            name: 'supply_info',
            component: () => import('@/views/personal/SupplyInfo'),
            meta: {
                requireAuth: true,
                title: '供应商信息'
            }
        },
        ]
    },
    {
        path:'*',
        name: 'not_found',
        component: () => import('@/views/404.vue'),
    }
]
})